package day4

import scala.collection.mutable.ArrayBuffer

class MyList {
  val arraybuffer = new ArrayBuffer[Int]()

  def this(i:Int*){
    this()
    for (elem <- i){
      arraybuffer.append(elem)
    }
  }

  def map() = {
    val arraybuffer2 = new ArrayBuffer[Int]()
    for (elem <- arraybuffer) {
      arraybuffer2.append(elem * 2)
    }
    arraybuffer2
  }

}

object Test2_map {
  def main(args: Array[String]): Unit = {
    val list = new MyList(1,2,3,4,5)
    val list2:ArrayBuffer[Int] = list.map()
    for (elem <- list2) {
      println(elem)
    }
  }

}
